package com.crm.controller;


import com.crm.constant.dto.BaseFxResponse;
import com.crm.entity.CrmArticle;
import com.crm.entity.CrmSite;
import com.crm.model.bo.ArticlePageBo;
import com.crm.model.bo.CrmSitePageBo;
import com.crm.model.dto.BasePageResult;
import com.crm.service.ICrmArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * CRM-文章表 前端控制器
 * </p>
 *
 * @author CRM_SYSTEM
 * @since 2022-03-30
 */
@RestController
@RequestMapping("/crm-article")
public class CrmArticleController {

    @Autowired
    private ICrmArticleService articleService;

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public BaseFxResponse<Long> saveArticle(@RequestBody @Validated CrmArticle article) {
        return articleService.saveArticle(article);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public BaseFxResponse<Long> updateArticle(@RequestBody @Validated CrmArticle article) {
        return articleService.updateArticle(article);
    }

    @RequestMapping(value = "/queryById", method = RequestMethod.POST)
    public BaseFxResponse<CrmArticle> queryById(@RequestParam("id") Long id) {
        return articleService.queryById(id);
    }

    @RequestMapping(value = "/query/page",method = RequestMethod.POST)
    public BaseFxResponse<BasePageResult<CrmArticle>> queryPage(@RequestBody @Validated ArticlePageBo articlePageBo){
        return articleService.queryPage(articlePageBo);
    }

    @RequestMapping(value = "/deleteById", method = RequestMethod.GET)
    public BaseFxResponse<Boolean> deleteByArticleId(@RequestParam("id") Long id) {
        return articleService.deleteByArticleId(id);
    }

}

